/** 标尺窗口类,在窗口中显示一些固定的text定位的类

  By setycyas @2024-12-22
*/

class RulerWindow {

  /* 构造函数,wSize = [width, height],
    infos是要显示的信息表,[[位置,颜色,文字]]
    x信息的横移位置
  */
  __New(wSize, infos, x := 0) {
    local i, v, params
    this._wSize := wSize
    this._infos := infos
    this._x := x
    this._gui := Gui("+Resize")
    for i, v in this._infos {
      params := "x" . this._x . " y" . v[1] . " +Background" . v[2]
      this._gui.Add("Text", params, v[3])
    }
  }
  
  ;显示窗口,可附加opt
  show(opt := "") {
    local params := "w" . this._wSize[1] . " h" . this._wSize[2]
    if (opt != "") {
      params := params . " " . opt
    }
    this._gui.show(params)
  }
  
}

/* 测试运行当前脚本
*/ if (A_ScriptName == "RulerWindow.2.ahk") {
  wSize := [200, 700]
  infos := [
    [307, "00FF00", "绿色魔法师"],
    [380, "CC00CC", "最后一关虫子"]
  ]
  x := 70
  
  rw := RulerWindow(wSize, infos, x)
  rw.show()
}